package external_libraries;

import javax.swing.JWindow;
import javax.swing.ImageIcon;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.File;

public class TransparentSplashScreen extends JWindow {

	private static final long serialVersionUID = 1L;
	private String currentDir = new File("").getAbsolutePath();
	// Get transparent image that will be use as splash screen image.
	Image bi = Toolkit.getDefaultToolkit().getImage(
			currentDir + "\\images\\db_images\\database_splash.png");

	ImageIcon ii = new ImageIcon(bi);

	@SuppressWarnings("deprecation")
	public TransparentSplashScreen() {
		try {
			setSize(ii.getIconWidth(), ii.getIconHeight());
			setLocationRelativeTo(null);
			show();
			// Thread.sleep(2000);
			setOpacity((float) 1.0);
		} catch (Exception exception) {
			exception.printStackTrace();
		}
	}

	// Paint transparent image onto JWindow
	public void paint(Graphics g) {
		g.drawImage(bi, 0, 0, this);
	}

	public void close() {
		dispose();
	}
}
